﻿using System;
using System.Diagnostics;
using System.Collections.Generic;
using System.Text;

namespace Acoris.Foundation
{
    /// <summary>
    /// 
    /// </summary>
    public sealed class Rope
    {
        internal RopeNode root;

        #region Constructor

        /// <summary>
        /// 
        /// </summary>
        /// <param name="text"></param>
        public Rope(string text) : this(text.ToCharArray(),0,text.Length) { }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="array"></param>
        /// <param name="count"></param>
        /// <param name="index"></param>
        public Rope(char[] array,int index,int count)
        {
            root = RopeNode.CreateFromArray(array,0,array.Length);
        }

        /// <summary>
        /// 
        /// </summary>
        public Rope()
        {

        }

        #endregion

        internal RopeNode Lock()
        {
            return root.Clone();
        }

        #region Insert / Concat

        

        public void InsertRange(int offset,string text)
        {
            InsertRange(offset, text.ToCharArray());
        }

        public void InsertRange(int offset,char[] array)
        {

        }

        internal void Insert(int offset,RopeNode ropeNode)
        {

        }

        #endregion

        public void Clear()
        {

        }

        /// <summary>
        /// gets total string count
        /// </summary>
        public int Count {
            get {
                return root?.length ?? 0;
            }
        }
    }

}
